import { defineStore } from 'pinia'
import { loadConfig } from '@/loadConfig'

export const useCounterStore = defineStore('counter', {
  state: () => ({
    gender: '',
    outfit: '',
    location: '',
    apiDomain: '',
    clearHistoryFlag: false,
  }),

  actions: {
    setClearHistoryFlag(flag) {
      this.clearHistoryFlag = flag
    },
    setGender(gender) {
      this.gender = gender
    },
    setOutfit(outfit) {
      this.outfit = outfit
    },
    setLocation(location) {
      this.location = location
    },
    async loadConfig() {
      const config = await loadConfig()
      this.apiDomain = config.API_DOMAIN
    },
  },
})